<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class Commessa extends Eloquent /*implements UserInterface, RemindableInterface*/ {
	
	private $rules = array(
			'numero' => 'required|numeric',
			'fase' => 'required|numeric',
			'id_strumento_misura' => 'required|alpha_dash',
			'articolo' => 'required|alpha_num',
			'macchina' => 'required|alpha_num',
			'data_inizio' => 'required|date',
	);
	
	private $errors;
	
	public function validate($data)
	{
		// make a new validator object
		$v = Validator::make($data, $this->rules);
	
		// check for failure
		if ($v->fails())
		{
			// set errors and return false
			$this->errors = $v->errors();
			return false;
		}
	
		// validation pass
		return true;
	}
	
	public function errors()
	{
		return $this->errors;
	}
}